<template>
  <div class="app-container">
    <el-row :gutter="20">
    <splitpanes :horizontal="this.$store.getters.device === 'mobile'" class="default-theme">
      <pane size="16">
          <el-col>
            <div class="head-container">
              <el-input v-model="deptName" placeholder="请输入材料" clearable size="small" prefix-icon="el-icon-search" style="margin-bottom: 20px" />
            </div>
            <div class="head-container">
              <el-tree :data="parentAccountName" :props="defaultProps" auto-expand-parent default-expand-all :expand-on-click-node="true"
            :filter-node-method="filterNode" ref="tree" highlight-current @node-click="handleNodeClick" />
            </div>
          </el-col>
        </pane>
        <pane size="84">
          <el-col>
            <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
               <el-form-item label="编号" prop="编号">
                 <el-input v-model="queryParams.编号" placeholder="请输入编号" clearable @keyup.enter.native="handleQuery" />
               </el-form-item>
               <el-form-item label="品名" prop="品名">
                 <el-input v-model="queryParams.品名" placeholder="请输入品名" clearable @keyup.enter.native="handleQuery" />
               </el-form-item>
               <el-form-item label="类别" prop="类别">
                 <el-input v-model="queryParams.类别" placeholder="请输入类别" clearable @keyup.enter.native="handleQuery" />
               </el-form-item>

               <el-form-item>
                 <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
                 <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
               </el-form-item>
            </el-form>
            
            <el-row :gutter="10" class="mb8">
              <el-col :span="1.5">
                <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
              </el-col>
             <!--  <el-col :span="1.5">
                <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single"
                  @click="handleUpdate">修改</el-button>
              </el-col> -->
              <el-col :span="1.5">
                <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple"
                  @click="handleDelete">删除</el-button>
              </el-col>
              <el-col :span="1.5">
                <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport">导出</el-button>
              </el-col>
              <el-col :span="1.5">
                <el-button type="primary" plain size="mini" @click="handleAddFinished">一键生成</el-button>
                <el-tooltip class="item" effect="dark" content="此功能可一键生成 产品、半成品、模具、花纸、辅助类生成档案)" placement="top-start">
                    <span  class="el-icon-warning-outline"  style="font-size: 15px;"></span>
                  </el-tooltip>
                <!-- <el-button type="info" plain icon="el-icon-upload" size="mini" @click="handleImport">一键生成</el-button> -->
              </el-col>
              <el-col :span="1.5">
            
              </el-col>
              <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
            </el-row>
            
          <el-table :data="tableData" border v-loading="loading"  @selection-change="handleSelectionChange">
            <el-table-column type="selection" width="55" align="center" />
            <el-table-column prop="图片" align="center" label="图片">
              <template slot-scope="scope">
                <image-preview :src="scope.row.图片" :width="50" :height="50" />
              </template>
            </el-table-column>
          
            <!-- 模具相关列 -->
            <template v-if="isMold && !isLabel">
              <el-table-column prop="编号" align="center" label="编号" />
              <el-table-column prop="代号" align="center" label="代号" />
              <el-table-column prop="品名" align="center" label="品名" />
              <el-table-column prop="规格" align="center" label="规格" />
              <el-table-column prop="类别" align="center" label="类别" />
              <el-table-column prop="规格" align="center" label="规格" />
              <el-table-column prop="主单位" align="center" label="主单位(见数据字典)" />
              <el-table-column prop="副单位" align="center" label="副单位(见数据字典)" />
              <el-table-column prop="转换率" align="center" label="转换率" />
              <el-table-column prop="当前库存" align="center" label="当前库存" />
              <el-table-column prop="安全库存" align="center" label="安全库存" />
              <el-table-column prop="最小库存" align="center" label="最小库存" />
              <el-table-column prop="最大库存" align="center" label="最大库存" />
            </template>
          
            <!-- 非模具相关列 -->
            <template v-if="!isMold">
              <el-table-column prop="productCode" align="center" label="货号" />
              <el-table-column prop="upperMoldTemperaturn" align="center" label="上模温度" />
              <el-table-column prop="lowerMoldTemperaturn" align="center" label="下模温度" />
              <el-table-column prop="furnaceWeight" align="center" label="浇粉重量" />
              <el-table-column prop="moldMaterial" align="center" label="材质" />
              <el-table-column prop="applicableMachine" align="center" label="适用机台" />
              <el-table-column prop="moldCavity" align="center" label="出模数" />
              <el-table-column prop="moldUnit" align="center" label="单位" />
              <el-table-column prop="moldSource" align="center" label="来源" />
              <el-table-column prop="moldType" align="center" label="模具类型" />
              <el-table-column prop="moldName" align="center" label="模具名称" />
              <el-table-column prop="moldCode" align="center" label="模具编号" />
            </template>
            
            
          
            <!-- 标签相关列 -->
            <template v-if="isLabel">
              <el-table-column label="底标编号" align="center" prop="labelCode" />
              <el-table-column label="图案" align="center" prop="labelPattern" />
            </template>
            
          
            <!-- 公共列 -->
             <el-table-column v-if="!isMold || isLabel" label="底标尺寸" align="center" prop="labelSize" />
            <el-table-column label="默认仓库" align="center" prop="defaultWarehouse" />
           
          
            <!-- 操作列 -->
            <el-table-column label="操作" align="center" width="150px" fixed="right">
              <template slot-scope="scope">
                <el-button size="mini" type="text" v-if="isEditMold" icon="el-icon-view" @click="handleVieWMold(scope.row)">查看模具信息</el-button>
                <el-button size="mini" type="text" v-if="!isMold" icon="el-icon-view" @click="handleMold(scope.row)">修改</el-button>
                <el-button size="mini" type="text" v-if="isMold" icon="el-icon-edit" @click="handleUpdate(scope.row)">修改</el-button>
                <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button>
                <el-button size="mini" type="text" v-if="isLabel" icon="el-icon-picture" @click="handleLabel(scope.row)">修改</el-button>
              </template>
            </el-table-column>
          </el-table>
        
        <pagination :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
          @pagination="getList" />
            
          </el-col>
        </pane>
      </splitpanes>
    </el-row>
    
    <!-- 产品列表 -->
          <el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
            <el-form ref="form" :model="form" :rules="rules" label-width="100px">
              
              <el-row>
                <el-col :span="12">
                  <el-form-item label="类别" prop="类别" >
                    <el-select v-model="form.类别" style="width: 220px;" :disabled="isEdit">
                       <el-option value="原料" label="原料"/>
                       <el-option value="辅料" label="辅料"/>
                       <el-option value="半成品" label="半成品"/>
                       <el-option value="成品" label="成品"/>
                       <el-option value="设备" label="设备"/>
                       <el-option value="模具" label="模具"/>
                       <el-option value="其他" label="其他"/>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="品名" prop="品名">
                    <el-input v-model="form.品名" placeholder="请输入品名" :disabled="isEdit" />
                  </el-form-item>
                </el-col>
              </el-row>
              
              <el-row>
                
                <el-col :span="12">
                  <el-form-item label="编号" prop="编号">
                    <el-input v-model="form.编号" placeholder="请输入编号" />
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="代号" prop="代号">
                    <el-input v-model="form.代号" placeholder="请输入代号" />
                  </el-form-item>
                </el-col>
                
              </el-row>
              
              <el-row>
                <el-col :span="12">
                  <el-form-item label="主单位" prop="主单位">
                    <el-input v-model="form.主单位" placeholder="请输入主单位" />
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="副单位" prop="副单位">
                    <el-input v-model="form.副单位" placeholder="请输入副单位" />
                  </el-form-item>
                </el-col>
              </el-row>
              
              <el-row>
                <el-col :span="12">
                  <el-form-item label="规格" prop="规格">
                    <el-input v-model="form.规格" placeholder="请输入规格" />
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="转换率" prop="转换率">
                    <el-input v-model="form.转换率" placeholder="请输入转换率" />
                  </el-form-item>
                </el-col>
              </el-row>
              
              <el-row>
                <el-col :span="12">
                  <el-form-item label="安全库存" prop="安全库存">
                     <el-input v-model="form.安全库存" placeholder="请输入安全库存 " />
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="当前库存" prop="当前库存">
                    <el-input v-model="form.当前库存" placeholder="请输入当前库存" />
                  </el-form-item>
                </el-col>
              </el-row>
            
              
              <el-row>
                <el-col :span="12">
                  <el-form-item label="最小库存" prop="最小库存">
                    <el-input v-model="form.最小库存" placeholder="请输入最小库存" />
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="最大库存" prop="最大库存">
                     <el-input v-model="form.最大库存" placeholder="请输入最大库存 " />
                  </el-form-item>
                </el-col>
              </el-row>
              
              <el-row>
                <el-col :span="12">
                  <el-form-item label="默认仓库" prop="defaultWarehouse">
                    <el-input v-model="form.defaultWarehouse" placeholder="请输入默认仓库" />
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="图片" prop="图片">
                    <ImageUpload v-model="form.图片" :limit="1"></ImageUpload>
                  </el-form-item>
                </el-col>
              </el-row>
              
            </el-form>
            <div slot="footer" class="dialog-footer">
              <el-button type="primary" @click="submitForm">确 定</el-button>
              <el-button @click="cancel">取 消</el-button>
            </div>
          </el-dialog>
          
          <!-- 一键生成 -->
           <el-dialog :title="titleReference" :visible.sync="openReference" width="800px" append-to-body>
            <el-form ref="formReference" :model="formReference" :rules="rulesReference" label-width="100px">
              <el-divider>产品信息</el-divider>
              <el-row>
                <el-col :span="12">
                  <el-form-item label="产品代号" prop="productCode">
                    <el-input v-model="formReference.productCode" placeholder="请输入产品代号" />
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="产品名称" prop="productName">
                    <el-input v-model="formReference.productName" placeholder="请输入产品名称" />
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="12">
                  <el-form-item label="产品种类" prop="productType">
                    <el-select v-model="formReference.productType" style="width: 280px;">
                       <el-option value="塑料" label="塑料"/>
                       <el-option value="密胺" label="密胺"/>
                    </el-select>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="单位" prop="unit">
                    <el-input v-model="formReference.unit" placeholder="请输入单位" />
                  </el-form-item>
                </el-col>
              </el-row>
              <!-- <el-row>
                <el-col :span="12">
                  <el-form-item label="主单位" prop="mainUnit">
                    <el-input v-model="formReference.主单位" placeholder="请输入主单位" />
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="转换率" prop="conversionRate">
                    <el-input v-model="formReference.转换率" placeholder="请输入转换率" />
                  </el-form-item>
                </el-col>
              </el-row> -->
              <el-divider>半成品信息</el-divider>
              <el-row>
                <el-col :span="12">
                  <el-form-item label="半成品代码" prop="semiFinishedCode">
                    <el-input v-model="formReference.半成品代码" placeholder="自动由产品代号生成，只是前缀不同" />
                  </el-form-item>
                </el-col>
                 <el-col :span="12">
                  <el-form-item label="克数" prop="kilogram">
                    <el-input v-model="formReference.kilogram" placeholder="请输入克数" />
                  </el-form-item>
                </el-col>
               </el-row>
               <el-divider>模具信息</el-divider>
              <el-row>
                <el-col :span="12">
                  <el-form-item label="模具代码" prop="moldCode">
                    <el-input v-model="formReference.模具代码" placeholder="自动由产品代号生成，只是前缀不同" />
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <el-form-item label="出数" prop="outputNumber">
                    <el-input v-model="formReference.出数" placeholder="请输入出数" />
                  </el-form-item>
                </el-col>
               
              </el-row>
              <el-row>
                <el-col :span="12">
                  <el-form-item  label="是否生成花纸" prop="isPrinting" label-width="auto">
                    <el-switch v-model="formReference.isPrinting"  active-value="是" active-text="是" inactive-value="否" inactive-text="否"></el-switch>
                  </el-form-item>
                </el-col>
                <el-col :span="12">
                  <!-- <el-form-item label="是否生成辅料" prop="isAccessory" label-width="auto">
                    <el-switch v-model="formReference.isAccessory"  active-value="是" active-text="是" inactive-value="否" inactive-text="否"></el-switch>
                  </el-form-item> -->
                  <!-- <el-form-item label="需要生成辅料" prop="isAccessory" label-width="auto">
                    <el-select multiple v-model="formReference.isAccessory" style="width: 280px;">
                       <el-option value="纸箱" label="纸箱"/>
                       <el-option value="条码" label="条码"/>
                       <el-option value="OPP袋" label="OPP袋"/>
                       <el-option value="PE袋" label="PE袋"/>
                       <el-option value="说明书" label="说明书"/>
                       <el-option value="彩标" label="彩标"/>
                       <el-option value="白纸" label="白纸"/>
                    </el-select>
                  </el-form-item> -->
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="12">
                  <el-form-item label="产品图片" prop="productImg">
                    <ImageUpload v-model="formReference.productImg" :limit="1"></ImageUpload>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-form>
            <div slot="footer" class="dialog-footer">
              <el-button type="primary" @click="submitFormReference">确 定</el-button>
              <el-button @click="cancelReference">取 消</el-button>
            </div>
           </el-dialog>
           
           <!-- 新增模具 -->
            <el-dialog :title="title" :visible.sync="openMold" width="1000px" append-to-body>
              <el-form ref="formMold" :model="formMold" :rules="rulesMold" label-width="100px">
                <el-row>
                  <el-col :span="8">
                    <el-form-item label="货号" prop="productCode">
                       <el-input v-model="formMold.productCode" placeholder="请输入货号" />
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="出模数" prop="moldCavity">
                      <el-input v-model="formMold.moldCavity" placeholder="请输入模穴" />
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="底标尺寸" prop="labelSize">
                      <el-input v-model="formMold.labelSize" placeholder="请输入底标尺寸" />
                    </el-form-item>
                  </el-col>
                  
                </el-row>
                <el-row>
                  <el-col :span="8">
                    <el-form-item label="模具编号" prop="moldCode">
                       <el-input v-model="formMold.moldCode" placeholder="请输入模具编号" />
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                     <el-form-item label="模具名称" prop="moldName">
                       <el-input v-model="formMold.moldName" placeholder="请输入模具名称" />
                     </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="模具类型" prop="moldType">
                       <el-select v-model="formMold.moldType" style="width: 220px;">
                          <el-option value="模具类" label="模具类"/>
                          <el-option value="塑胶类模具" label="塑胶类模具"/>
                          <el-option value="密胺类模具" label="密胺类模具"/>
                       </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="8">
                    <el-form-item label="单位" prop="moldUnit">
                       <el-input v-model="formMold.moldUnit" placeholder="请输入单位" />
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="来源" prop="moldSource">
                       <el-select v-model="formMold.moldSource" style="width: 220px;">
                          <el-option value="自制" label="自制"/>
                          <el-option value="采购" label="采购"/>
                          <el-option value="订购" label="订购"/>
                       </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="材质" prop="moldMaterial">
                       <el-input v-model="formMold.moldMaterial" placeholder="请输入材质" />
                    </el-form-item>
                  </el-col>
                </el-row>
                
                <el-row>
                  <el-col :span="8">
                    <el-form-item label="浇粉重量" prop="furnaceWeight">
                      <el-input v-model="formMold.furnaceWeight" placeholder="请输入浇粉重量" />
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="上模温度" prop="upperMoldTemperaturn">
                      <el-input v-model="formMold.upperMoldTemperaturn" placeholder="请输入上模温度" />
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-form-item label="下模温度" prop="lowerMoldTemperaturn">
                      <el-input v-model="formMold.lowerMoldTemperaturn" placeholder="请输入下模温度" />
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="8">
                    <el-form-item label="适用机台" prop="applicableMachine">
                      <el-input v-model="formMold.applicableMachine" placeholder="请输入适用机台" />
                    </el-form-item>
                  </el-col>
                  <el-col :span="8">
                    <el-col :span="12">
                  <el-form-item label="默认仓库" prop="defaultWarehouse">
                    <el-input v-model="formMold.defaultWarehouse" style="width: 220px;" placeholder="请输入默认仓库" />
                  </el-form-item>
                </el-col>
                  </el-col>
                </el-row>
                
                <el-divider>素面成型</el-divider>
                <el-row>
                  <el-col :span="6">
                    <el-form-item label="排气次数" prop="bareFaceExhaustFrequency">
                      <el-input v-model="formMold.bareFaceExhaustFrequency" placeholder="请输入排气次数" />
                    </el-form-item>
                  </el-col>
                  <el-col :span="6">
                    <el-form-item label="初压" prop="bareFaceInitialPressure">
                      <el-input v-model="formMold.bareFaceInitialPressure" placeholder="请输入初压" />
                    </el-form-item>
                  </el-col>
                  <el-col :span="6">
                    <el-form-item label="成型压力" prop="bareFaceFormingPressure">
                      <el-input v-model="formMold.bareFaceFormingPressure" placeholder="请输入成型压力" />
                    </el-form-item>
                  </el-col>
                  <el-col :span="6">
                    <el-form-item label="成型时间" prop="bareFaceFormingTime">
                      <el-input v-model="formMold.bareFaceFormingTime" placeholder="请输入成型时间" />
                    </el-form-item>
                  </el-col>
                </el-row>
                
                <el-row>
                  <el-col :span="6">
                    <el-form-item label="单个标准用料" prop="bareFacesingleStandardMaterial">
                      <el-input v-model="formMold.bareFacesingleStandardMaterial" placeholder="请输入单个标准用料" />
                    </el-form-item>
                  </el-col>
                  <el-col :span="6">
                    <el-form-item label="班产定额" prop="bareFaceBatchQuota">
                      <el-input v-model="formMold.bareFaceBatchQuota" placeholder="请输入班产定额" />
                    </el-form-item>
                  </el-col>
                  <el-col :span="6">
                    <el-form-item label="单模时间" prop="bareFaceSingleMoldTime">
                      <el-input v-model="formMold.bareFaceSingleMoldTime" placeholder="请输入单模时间" />
                    </el-form-item>
                  </el-col>
                  <el-col :span="6">
                    <el-form-item label="标准工资" prop="bareFaceStandardWage">
                      <el-input v-model="formMold.bareFaceStandardWage" placeholder="请输入标准工资" />
                    </el-form-item>
                  </el-col>
                </el-row>
                
                <el-divider>贴花成型</el-divider>
                <el-row>
                  <el-col :span="6">
                    <el-form-item label="排气次数" prop="appliqueExhaustFrequency">
                      <el-input v-model="formMold.appliqueExhaustFrequency" placeholder="请输入排气次数" />
                    </el-form-item>
                  </el-col>
                  <el-col :span="6">
                    <el-form-item label="初压" prop="appliqueInitialPressure">
                      <el-input v-model="formMold.appliqueInitialPressure" placeholder="请输入初压" />
                    </el-form-item>
                  </el-col>
                  <el-col :span="6">
                    <el-form-item label="成型压力" prop="appliqueFormingPressure">
                      <el-input v-model="formMold.appliqueFormingPressure" placeholder="请输入成型压力" />
                    </el-form-item>
                  </el-col>
                  <el-col :span="6">
                    <el-form-item label="成型时间" prop="appliqueFormingTime">
                      <el-input v-model="formMold.appliqueFormingTime" placeholder="请输入成型时间" />
                    </el-form-item>
                  </el-col>
                </el-row>
                
                <el-row>
                  <el-col :span="6">
                    <el-form-item label="单个光粉用量" prop="appliqueSinglePowderDosage">
                      <el-input v-model="formMold.appliqueSinglePowderDosage" placeholder="请输入单个光粉用量" />
                    </el-form-item>
                  </el-col>
                  <el-col :span="6">
                    <el-form-item label="适用原料流量" prop="appliqueMaterialFlow">
                      <el-input v-model="formMold.appliqueMaterialFlow" placeholder="请输入适用原料流量" />
                    </el-form-item>
                  </el-col>
                  <el-col :span="6">
                    <el-form-item label="测试班产定额" prop="appliqueBatchQuota">
                      <el-input v-model="formMold.appliqueBatchQuota" placeholder="请输入测试班产定额" />
                    </el-form-item>
                  </el-col>
                  <el-col :span="6">
                    <el-form-item label="成型单价" prop="appliqueFormingPrice">
                      <el-input v-model="formMold.appliqueFormingPrice" placeholder="请输入成型单价" />
                    </el-form-item>
                  </el-col>
                </el-row>
                
                <el-divider>加金成型</el-divider>
                <el-row>
                  <el-col :span="6">
                    <el-form-item label="排气次数" prop="addGoldExhaustFrequency">
                      <el-input v-model="formMold.addGoldExhaustFrequency" placeholder="请输入排气次数" />
                    </el-form-item>
                  </el-col>
                  <el-col :span="6">
                    <el-form-item label="初压" prop="addGoldInitialPressure">
                      <el-input v-model="formMold.addGoldInitialPressure" placeholder="请输入初压" />
                    </el-form-item>
                  </el-col>
                  <el-col :span="6">
                    <el-form-item label="成型压力" prop="addGoldFormingPressure">
                       <el-input v-model="formMold.addGoldFormingPressure" placeholder="请输入成型压力" />
                    </el-form-item>
                  </el-col>
                  <el-col :span="6">
                    <el-form-item label="成型时间" prop="addGoldFormingTime">
                      <el-input v-model="formMold.addGoldFormingTime" placeholder="请输入成型时间" />
                    </el-form-item>
                  </el-col>
                </el-row>
                
                <el-row>
                  <el-col :span="6">
                    <el-form-item label="产品标准克重" prop="addGoldProductWeight">
                      <el-input v-model="formMold.addGoldProductWeight" placeholder="请输入产品标准克重" />
                    </el-form-item>
                  </el-col>
                  <el-col :span="6">
                    <el-form-item label="工艺" prop="addGoldTechnology">
                      <el-input v-model="formMold.addGoldTechnology" placeholder="请输入工艺" />
                    </el-form-item>
                  </el-col>
                  <el-col :span="6">
                    <el-form-item label="模具等级" prop="addGoldMoldGrade">
                      <el-select v-model="formMold.addGoldMoldGrade" placeholder="请输入模具等级">
                         <el-option value="A" label="A"></el-option>
                         <el-option value="B" label="B"></el-option>
                         <el-option value="C" label="C"></el-option>
                         <el-option value="D" label="D"></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>
                
                <el-row>
                <el-col :span="12">
                  <el-form-item label="图片" prop="图片">
                    <ImageUpload v-model="form.图片" :limit="1"></ImageUpload>
                  </el-form-item>
                </el-col>
              </el-row>
                
              </el-form>
              
              <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="submitFormMold">确 定</el-button>
                <el-button @click="cancelMold">取 消</el-button>
              </div>
              
            </el-dialog>
            
            <!-- 查看模具 -->
             <el-dialog :title="titleViewMold" :visible.sync="openViewMold" width="1000px" append-to-body>
              <el-table :data="moldList">
                  <el-table-column label="货号" align="center" prop="productCode" />
                  <el-table-column label="模具编号" align="center" prop="moldCode" />
                  <el-table-column label="模具名称" align="center" prop="moldName" />
                  <el-table-column label="单位" align="center" prop="moldUnit" />
                  <el-table-column label="模具类型" align="center" prop="moldType" />
                  <el-table-column label="来源" align="center" prop="moldSource" />
                  <el-table-column label="出模数" align="center" prop="moldCavity" />
                  <el-table-column label="适用机台" align="center" prop="applicableMachine" />
                  <el-table-column label="材质" align="center" prop="moldMaterial" />
                  <el-table-column label="浇粉重量" align="center" prop="furnaceWeight" />
                  <el-table-column label="上模温度" align="center" prop="upperMoldTemperaturn" />
                  <el-table-column label="下模温度" align="center" prop="lowerMoldTemperaturn" />
                </el-table>
              <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="cancelViewMold">关闭</el-button>
              </div>
             </el-dialog>
             
             <!-- 底标 -->
              <el-dialog :title="title" :visible.sync="openBottomMark" width="500px" append-to-body>
                <el-form ref="formBottomMark" :model="formBottomMark" :rules="rulesBottomMark" label-width="100px">
                      <el-form-item label="底标编号" prop="labelCode">
                        <el-input v-model="formBottomMark.labelCode" placeholder="请输入底标名称" />
                      </el-form-item>
                      <el-form-item label="尺寸大小" prop="labelSize">
                        <el-input v-model="formBottomMark.labelSize" placeholder="请输入尺寸大小" />
                      </el-form-item>
                      <el-form-item label="图案" prop="labelPattern">
                        <el-input v-model="formBottomMark.labelPattern" placeholder="请输入图案" />
                      </el-form-item>
                      <el-form-item label="图片" prop="图片">
                        <ImageUpload v-model="formBottomMark.图片" :limit="1"></ImageUpload>
                      </el-form-item>
                      <el-form-item label="默认仓库" prop="defaultWarehouse">
                    <el-input v-model="formBottomMark.defaultWarehouse" placeholder="请输入默认仓库" />
                  </el-form-item>

                </el-form>
                <div slot="footer" class="dialog-footer">
                  <el-button type="primary" @click="submitFormBottomMark">确 定</el-button>
                  <el-button @click="cancelBottomMark">取 消</el-button>
                </div>
              </el-dialog>
  </div>
</template>

<script>
import ImageUpload from '@/components/ImageUpload';
import { Splitpanes, Pane } from "splitpanes";
import "splitpanes/dist/splitpanes.css";
export default {
  components: { Splitpanes, Pane },
  data() {
    return {
      // 标题
      title:null,
      // 总条数
      total:0,
      // 打开弹出框
      open:false,
      // 表格
      form:{},
      // 校验
      rules:{},
      rulesMold:{},
      rulesReference:{},
      importType:'',
      deptName:'',
      parentAccountName: [{
        label: '物品列表',
        children: [{
          label: '原材料',
          children: [{
            label: '塑胶',
            children: [{
              label: '塑胶原料',
              children: [{
                label: '塑胶新料'
              }]
            }, {
              label: '色粉',
            },]
          }, {
            label: '密胺',
            children: [{
              label: 'A1料'
            }, {
              label: 'A3料'
            }, {
              label: 'A5料'
            }, {
              label: '光粉'
            }, {
              label: '竹木粉'
            },
            ]
          },{
            label: '花纸'
          }]
        }, {
          label: '辅料类',
          children:[{
            label:'纸箱',
          },{
            label:'条码',
          },{
            label:'胶袋',
            children:[{
              label:'OPP袋'
            },{
              label:'PE袋'
            }]
          },{
            label:'说明书'
          },{
            label:'彩标'
          },{
            label:'白纸'
          }]
        }, {
          label: '半成品类',
          children:[{
            label:'塑胶半成品类',
          },{
            label:'密胺半成品类',
          }]
        },
        {
          label: '成品类',
          children:[{
            label:'塑胶成品类',
          },{
            label:'密胺成品类',
          }]
        },
        {
          label: '其他类',
          children:[{
            label:'办公用品'
          },{
            label:'五金'
          },{
            label:'五金/辅料'
          },{
            label:'工程用具'
          },{
            label:'研磨'
          },{
            label:'食堂'
          }]
        },
        {
          label: '设备类',
          children:[{
            label:'注塑类'
          },{
            label:'密胺类'
          },{
            label:'模具类'
          },{
            label:'工程类'
          }]
        },
        {
          label: '模具类',
          children:[{
            label:'塑胶类模具'
          },{
            label:'密胺类模具'
          }]
        },{
          label: '底标类',
          children:[{
            label:'底标'
          }]
        }]
      }],
      defaultProps: {
        children: 'children',
        label: 'label'
      },
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      showSearch: true,
      single: false,
      multiple: false,
      tableData: [],
      tableData1: [
  {
    label: '原材料',
    children: [
      {
        编号: '01020002',
        代号: '0102106',
        品名: '钛白粉',
        规格: '',
        类别: '蜜胺',
        主单位: '公斤',
        副单位: '吨',
        转换率: '1000',
        货位: 'B2',
        是否需要货位: '是',
        ABC编码: 'A001',
        批号: '20230801',
        条形码: '693456781234',
        来源: '外购',
        是否管制: '否',
        重量单位: '克',
        单位重量: '1000',
        体积单位: '立方米',
        单位体积: '0.5',
        保质天数: '180',
        安全库存: '5000',
        最小库存: '1000',
        最大库存: '20000',
        税率: '0.13',
        采购方式: '定期采购',
        采购提前期: '3',
        生产提前期: '0',
        价格: '85',
        状态: '正在使用'
      },
      {
        编号: '01020006',
        代号: 'A1-60098',
        品名: '余姚A1-60098',
        规格: '余姚A1-60098',
        类别: '蜜胺',
        主单位: '公斤',
        副单位: '吨',
        转换率: '1000',
        货位: 'B3',
        是否需要货位: '是',
        ABC编码: 'A002',
        批号: '20230802',
        条形码: '693456781235',
        来源: '外购',
        是否管制: '否',
        重量单位: '克',
        单位重量: '800',
        体积单位: '立方米',
        单位体积: '0.3',
        保质天数: '365',
        安全库存: '8000',
        最小库存: '2000',
        最大库存: '30000',
        税率: '0.13',
        采购方式: '定期采购',
        采购提前期: '5',
        生产提前期: '0',
        价格: '45',
        状态: '正在使用'
      },
      {
        编号: '01020008',
        代号: 'A1-70111',
        品名: 'A1-70111余姚',
        规格: 'A1-70111余姚',
        类别: '蜜胺',
        主单位: '公斤',
        副单位: '吨',
        转换率: '1000',
        货位: 'B3',
        是否需要货位: '是',
        ABC编码: 'A002',
        批号: '20230802',
        条形码: '693456781235',
        来源: '外购',
        是否管制: '否',
        重量单位: '克',
        单位重量: '800',
        体积单位: '立方米',
        单位体积: '0.3',
        保质天数: '365',
        安全库存: '8000',
        最小库存: '2000',
        最大库存: '30000',
        税率: '0.13',
        采购方式: '定期采购',
        采购提前期: '5',
        生产提前期: '0',
        价格: '45',
        状态: '正在使用'
      },
      {
        编号: '01020003',
        代号: 'A5-M30009W',
        品名: 'A5-M30009W',
        规格: '余姚A5-M3000',
        类别: '蜜胺',
        主单位: '公斤',
        副单位: '吨',
        转换率: '1000',
        货位: 'B3',
        是否需要货位: '是',
        ABC编码: 'A002',
        批号: '20230802',
        条形码: '693456781235',
        来源: '外购',
        是否管制: '否',
        重量单位: '克',
        单位重量: '800',
        体积单位: '立方米',
        单位体积: '0.3',
        保质天数: '365',
        安全库存: '8000',
        最小库存: '2000',
        最大库存: '30000',
        税率: '0.13',
        采购方式: '定期采购',
        采购提前期: '5',
        生产提前期: '0',
        价格: '45',
        状态: '正在使用'
      },
      {
        编号: '01020005',
        代号: 'A5-M40001W',
        品名: 'A5-M40001W',
        规格: '余姚A5-M4000',
        类别: '蜜胺',
        主单位: '公斤',
        副单位: '吨',
        转换率: '1000',
        货位: 'B3',
        是否需要货位: '是',
        ABC编码: 'A002',
        批号: '20230802',
        条形码: '693456781235',
        来源: '外购',
        是否管制: '否',
        重量单位: '克',
        单位重量: '800',
        体积单位: '立方米',
        单位体积: '0.3',
        保质天数: '365',
        安全库存: '8000',
        最小库存: '2000',
        最大库存: '30000',
        税率: '0.13',
        采购方式: '定期采购',
        采购提前期: '5',
        生产提前期: '0',
        价格: '45',
        状态: '正在使用'
      },
      {
        编号: '01020004',
        代号: 'A5-M70004W',
        品名: 'A5-M70004W',
        规格: '余姚A5-M7000',
        类别: '蜜胺',
        主单位: '公斤',
        副单位: '吨',
        转换率: '1000',
        货位: 'B3',
        是否需要货位: '是',
        ABC编码: 'A002',
        批号: '20230802',
        条形码: '693456781235',
        来源: '外购',
        是否管制: '否',
        重量单位: '克',
        单位重量: '800',
        体积单位: '立方米',
        单位体积: '0.3',
        保质天数: '365',
        安全库存: '8000',
        最小库存: '2000',
        最大库存: '30000',
        税率: '0.13',
        采购方式: '定期采购',
        采购提前期: '5',
        生产提前期: '0',
        价格: '45',
        状态: '正在使用'
      }
    ]
  },
  {
    label: '辅料类',
    children: [
      {
        编号: '020002',
        代号: 'WX-YL0158-3',
        品名: 'YL0158-3外箱',
        类别: '辅料02',
        主单位: '个',
        副单位: '',
        转换率: '',
        货位: 'C1',
        是否需要货位: '是',
        ABC编码: 'B101',
        批号: '20230803',
        条形码: '693456781236',
        来源: '外购',
        是否管制: '否',
        重量单位: '克',
        单位重量: '200',
        体积单位: '立方米',
        单位体积: '0.1',
        保质天数: '180',
        安全库存: '3000',
        最小库存: '500',
        最大库存: '10000',
        税率: '0.13',
        采购方式: '按需采购',
        采购提前期: '2',
        生产提前期: '0',
        价格: '0',
        状态: '正在使用'
      },
      {
        编号: '020003',
        代号: 'NH-YL086510',
        品名: 'YL086510内盒',
        类别: '辅料02',
        主单位: '个',
        副单位: '',
        转换率: '',
        货位: 'C1',
        是否需要货位: '是',
        ABC编码: 'B101',
        批号: '20230803',
        条形码: '693456781236',
        来源: '外购',
        是否管制: '否',
        重量单位: '克',
        单位重量: '200',
        体积单位: '立方米',
        单位体积: '0.1',
        保质天数: '180',
        安全库存: '3000',
        最小库存: '500',
        最大库存: '10000',
        税率: '0.13',
        采购方式: '按需采购',
        采购提前期: '2',
        生产提前期: '0',
        价格: '0',
        状态: '正在使用'
      },
      {
        编号: '02010001',
        代号: '	WX-YL897',
        品名: '	YL897外箱',
        类别: '辅料0201',
        主单位: '个',
        副单位: '',
        转换率: '',
        货位: 'C1',
        是否需要货位: '是',
        ABC编码: 'B101',
        批号: '20230803',
        条形码: '693456781236',
        来源: '外购',
        是否管制: '否',
        重量单位: '克',
        单位重量: '200',
        体积单位: '立方米',
        单位体积: '0.1',
        保质天数: '180',
        安全库存: '3000',
        最小库存: '500',
        最大库存: '10000',
        税率: '0.13',
        采购方式: '按需采购',
        采购提前期: '2',
        生产提前期: '0',
        价格: '0',
        状态: '正在使用'
      }
    ]
  },
  {
    label: '半成品类',
    children: [
      {
        编号: '03010001',
        代号: 'SB-YL7129杯',
        品名: '杯子',
        规格: '',
        类别: '半成品0301',
        主单位: '个',
        副单位: '箱',
        转换率: '1:50',
        货位: 'A1',
        是否需要货位: '是',
        ABC编码: 'A101',
        批号: '20230805',
        条形码: '123456789012',
        来源: '自制',
        是否管制: '否',
        重量单位: '克',
        单位重量: '600',
        体积单位: '立方米',
        单位体积: '0.2',
        保质天数: '30',
        安全库存: '2000',
        最小库存: '500',
        最大库存: '8000',
        税率: '0.13',
        采购方式: '按单采购',
        采购提前期: '1',
        生产提前期: '2',
        价格: '28',
        状态: '正在使用',
        包装数: '50'
      },
      {
        编号: '030001',
        代号: 'SB-YL74005',
        品名: '直条纹水杯',
        类别: '半成品0301',
        主单位: '个',
        副单位: '箱',
        转换率: '1:100',
        货位: 'A2',
        是否需要货位: '是',
        ABC编码: 'A102',
        批号: '20230806',
        条形码: '123456789013',
        来源: '自制',
        是否管制: '否',
        重量单位: '克',
        单位重量: '150',
        体积单位: '立方米',
        单位体积: '0.05',
        保质天数: '60',
        安全库存: '3000',
        最小库存: '800',
        最大库存: '12000',
        税率: '0.13',
        采购方式: '按单采购',
        采购提前期: '1',
        生产提前期: '1',
        价格: '15',
        状态: '正在使用',
        包装数: '100'
      }
    ]
  },
  {
    label: '成品类',
    children: [
      {
        编号: '040004',
        代号: 'YL0236073',
        品名: '高底深碗',
        类别: '成品04',
        主单位: '只',
        副单位: '箱',
        转换率: '1:20',
        货位: 'D1',
        是否需要货位: '是',
        ABC编码: 'A201',
        批号: '20230810',
        条形码: '694123456789',
        来源: '自制',
        是否管制: '否',
        重量单位: '克',
        单位重量: '750',
        体积单位: '立方米',
        单位体积: '0.25',
        保质天数: '365',
        安全库存: '1000',
        最小库存: '200',
        最大库存: '5000',
        税率: '0.13',
        采购方式: '按单生产',
        采购提前期: '0',
        生产提前期: '3',
        价格: '0',
        状态: '正在使用',
        包装数: '20'
      },
      {
        编号: '040009',
        代号: 'YL134-2',
        品名: '托盘两件套',
        类别: '成品04',
        主单位: '只',
        副单位: '箱',
        转换率: '1:20',
        货位: 'D1',
        是否需要货位: '是',
        ABC编码: 'A201',
        批号: '20230810',
        条形码: '694123456789',
        来源: '自制',
        是否管制: '否',
        重量单位: '克',
        单位重量: '750',
        体积单位: '立方米',
        单位体积: '0.25',
        保质天数: '365',
        安全库存: '1000',
        最小库存: '200',
        最大库存: '5000',
        税率: '0.13',
        采购方式: '按单生产',
        采购提前期: '0',
        生产提前期: '3',
        价格: '0',
        状态: '正在使用',
        包装数: '20'
      }
    ]
  },
  {
    label: '模具类',
    children: [
      {
        moldCode: 'MJ-2023A',
        moldName: '密胺碗成型模',
        moldType: '注塑模具',
        applicableMachine: 'HT-2800T',
        moldMaterial: '模具钢P20',
        lowerMoldTemperaturn: '160℃',
        upperMoldTemperaturn: '155℃',
        furnaceWeight: '850g',
        moldCavity: '4穴',
        moldSource: '外协定制',
        moldUnit: '套'
      },
      {
        moldCode: 'MYL320A',
        moldName: '圆型多功能盒',
        moldType: '注塑模具05',
        applicableMachine: 'HT-2800T',
        moldMaterial: '模具钢P20',
        lowerMoldTemperaturn: '160℃',
        upperMoldTemperaturn: '155℃',
        furnaceWeight: '850g',
        moldCavity: '4穴',
        moldSource: '外协定制',
        moldUnit: '付'
      }
    ]
  },
  {
    label: '其他类'
    [
      {
        编号: '070001',
        代号: 'WJ0001',
        品名: 'M6*101螺丝',
        类别: '其他类07',
        主单位: '个',
        副单位: '箱',
        转换率: '1:100',
        货位: 'A2',
        是否需要货位: '是',
        ABC编码: 'A102',
        批号: '20230806',
        条形码: '123456789013',
        来源: '自制',
        是否管制: '否',
        重量单位: '克',
        单位重量: '150',
        体积单位: '立方米',
        单位体积: '0.05',
        保质天数: '60',
        安全库存: '3000',
        最小库存: '800',
        最大库存: '12000',
        税率: '0.13',
        采购方式: '按单采购',
        采购提前期: '1',
        生产提前期: '1',
        价格: '15',
        状态: '正在使用',
        包装数: '100'
      },
      {
        编号: '070002',
        代号: 'DM-302065',
        品名: '刀模302065',
        类别: '其他类07',
        主单位: '个',
        副单位: '箱',
        转换率: '1:100',
        货位: 'A2',
        是否需要货位: '是',
        ABC编码: 'A102',
        批号: '20230806',
        条形码: '123456789013',
        来源: '自制',
        是否管制: '否',
        重量单位: '克',
        单位重量: '150',
        体积单位: '立方米',
        单位体积: '0.05',
        保质天数: '60',
        安全库存: '3000',
        最小库存: '800',
        最大库存: '12000',
        税率: '0.13',
        采购方式: '按单采购',
        采购提前期: '1',
        生产提前期: '1',
        价格: '15',
        状态: '正在使用',
        包装数: '100'
      }
    ]
  },
  {
    label: '设备类'
    [
      {
        编号: '06010001',
        代号: '01#',
        品名: '注塑机',
        类别: '设备类0601',
        主单位: '台',
        副单位: '',
        转换率: '',
        货位: 'A2',
        是否需要货位: '是',
        ABC编码: 'A102',
        批号: '20230806',
        条形码: '123456789013',
        来源: '自制',
        是否管制: '否',
        重量单位: '克',
        单位重量: '150',
        体积单位: '立方米',
        单位体积: '0.05',
        保质天数: '60',
        安全库存: '3000',
        最小库存: '800',
        最大库存: '12000',
        税率: '0.13',
        采购方式: '按单采购',
        采购提前期: '1',
        生产提前期: '1',
        价格: '15',
        状态: '正在使用',
        包装数: '100'
      },
      {
        编号: '06010002',
        代号: '02#',
        品名: '注塑机',
        类别: '设备类0601',
        主单位: '台',
        副单位: '',
        转换率: '',
        货位: 'A2',
        是否需要货位: '是',
        ABC编码: 'A102',
        批号: '20230806',
        条形码: '123456789013',
        来源: '自制',
        是否管制: '否',
        重量单位: '克',
        单位重量: '150',
        体积单位: '立方米',
        单位体积: '0.05',
        保质天数: '60',
        安全库存: '3000',
        最小库存: '800',
        最大库存: '12000',
        税率: '0.13',
        采购方式: '按单采购',
        采购提前期: '1',
        生产提前期: '1',
        价格: '15',
        状态: '正在使用',
        包装数: '100'
      }
    ]
  }
],
      loading: false,
      ids: [],
      isEdit: false,
      
      // 记录修改的索引
      index:0,
      
      // 一键生成
      titleReference: "一键生成物品",
      openReference: false,
      formReference: {},
      // 模具
      openMold: false,
      formMold: {},
      moldrules: {},
      
      // 记录是否模具
      isMold: false,
      // 查看半成品里面模具
      isEditMold: false,
      titleViewMold:'',
      openViewMold: false,
      moldList: [
      // 密胺材质数据
      {
        productCode: 'MD001',
        moldCode: 'M001MD',
        moldName: '密胺餐盘',
        moldUnit: '件',
        moldType: '餐具',
        moldSource: '国内生产',
        moldCavity: 24, // 一模多穴数量
        applicableMachine: '注塑机M1',
        moldMaterial: '密胺树脂',
        furnaceWeight: 300, // 假设的每次注塑重量，单位g
        upperMoldTemperaturn: 160, // 上模温度，单位℃
        lowerMoldTemperaturn: 150, // 下模温度，单位℃
      },
      {
        productCode: 'MD002',
        moldCode: 'M002MD',
        moldName: '密胺杯子',
        moldUnit: '个',
        moldType: '餐具',
        moldSource: '进口模具',
        moldCavity: 12,
        applicableMachine: '注塑机M2',
        moldMaterial: '密胺树脂',
        furnaceWeight: 150,
        upperMoldTemperaturn: 165,
        lowerMoldTemperaturn: 155,
      },
 
      // 塑胶材质数据
      {
        productCode: 'PL001',
        moldCode: 'M001PL',
        moldName: '塑胶碗',
        moldUnit: '个',
        moldType: '餐具',
        moldSource: '自主研发',
        moldCavity: 32,
        applicableMachine: '注塑机P1',
        moldMaterial: '聚丙烯(PP)',
        furnaceWeight: 80,
        upperMoldTemperaturn: 50, // 塑胶模具温度通常较低
        lowerMoldTemperaturn: 50,
      },
      {
        productCode: 'PL002',
        moldCode: 'M002PL',
        moldName: '塑胶餐叉',
        moldUnit: '把',
        moldType: '餐具',
        moldSource: '合作厂家',
        moldCavity: 96, // 高产量的模具设计
        applicableMachine: '注塑机P2',
        moldMaterial: '聚苯乙烯(PS)',
        furnaceWeight: 10,
        upperMoldTemperaturn: 45,
        lowerMoldTemperaturn: 45,
      },
      {
        productCode: 'PL003',
        moldCode: 'M003PL',
        moldName: '可降解塑胶餐盒',
        moldUnit: '盒',
        moldType: '环保餐具',
        moldSource: '国内环保厂家',
        moldCavity: 48,
        applicableMachine: '注塑机P3',
        moldMaterial: 'PLA（聚乳酸）',
        furnaceWeight: 200,
        upperMoldTemperaturn: 60, // PLA材料需要较高的模具温度以保持形状稳定性
        lowerMoldTemperaturn: 60,
      }
      ],
    // 底标
    isLabel: false,
    openBottomMark: false,
    formBottomMark: {},
    rulesBottomMark: {},
    }
  },
  mounted() {
    this.handleNodeClick(this.parentAccountName[0].children[0])
  },
  
  methods: {
    getList(){},
    // 底标
    handleAddBottomMark(){
      this.title = '新增底标'
      this.openBottomMark = true;
      this.formBottomMark = {}
    },
    handleLabel(row){
      this.title = '修改底标'
      this.openBottomMark = true;
      this.formBottomMark = row;
      this.index = this.tableData1[5].children.indexOf(row)
    },
    submitFormBottomMark(){
      this.$refs['formBottomMark'].validate((valid) => {
        if (valid) {
          if(this.title == '修改底标'){
            this.tableData1[5].children[this.index] = this.formBottomMark
            this.$message.success('修改成功');
            this.openBottomMark = false;
          } else if(this.title == '新增底标' || this.title == '查看底标类'){
            this.tableData1.push({
              label: '底标',
              children: [this.formBottomMark]
            })
            this.$message.success('新增成功');
            this.openBottomMark = false;
          }
          }
      });
    },
    cancelBottomMark(){
      this.openBottomMark = false;
      this.formBottomMark = {}
    },
    handleMold(row){
      this.formMold = row;
      this.title == '修改模具'
      this.openMold = true;
    },
    // 查看模具
    handleVieWMold(row){
      this.formMold = this.tableData1[4].children;
      this.titleViewMold == '查看模具'
      this.openViewMold = true;
    },
    cancelViewMold(){
      this.openViewMold = false;
    },
    handleAddFinished(){
      this.titleReference = "一键生成物品"
      this.openReference = true;
    },
    
    
    filterNode(value, data) {
      if (!value) return true;
      return data.label.indexOf(value) !== -1;
    },
    handleNodeClick(data) {
      this.title = '新增' + data.label
      this.isMold = true;
      this.isEditMold = false;
      this.isLabel = false;
      if (data.label === '原材料') {
        this.tableData = this.tableData1[0].children;
      } 
      else if(data.label === "花纸"){
        /* this.$alert("此分类下不建档", "提示", {
          confirmButtonText: '关闭',
        }) */
      }
      else if (data.label === '辅料类') {
        this.tableData = this.tableData1[1].children;
        this.isShow1 = false;
        this.isShow2 = false;
        this.isShow3 = false;
        this.isShow4 = true;
        this.isShow5 = false;
        this.isShow6 = false;
       /*  this.$alert("此分类下不建档", "提示", {
          confirmButtonText: '关闭',
        }) */
      } else if(data.label === "纸箱"){
        /* this.$alert("此分类下不建档", "提示", {
          confirmButtonText: '关闭',
        }) */
      } else if (data.label === '条码') {
        /* this.$alert("此分类下不建档", "提示", {
          confirmButtonText: '关闭',
        }) */
      } else if(data.label === "胶袋"){
        /* this.$alert("此分类下不建档", "提示", {
          confirmButtonText: '关闭',
        }) */
      }
      else if (data.label === '说明书') {
        /* this.$alert("此分类下不建档", "提示", {
          confirmButtonText: '关闭',
        }) */
      } else if (data.label === '彩标') {
       /*  this.$alert("此分类下不建档", "提示", {
          confirmButtonText: '关闭',
        }) */
      } else if (data.label === '白纸') {
        /* this.$alert("此分类下不建档", "提示", {
          confirmButtonText: '关闭',
        }) */
      }
      else if (data.label === '半成品类') {
        this.isEditMold = true;
        this.tableData = this.tableData1[2].children;
        } else if (data.label === '塑胶半成品类') {
          this.isEditMold = true;
        }
        else if (data.label === '密胺半成品类') {
          this.isEditMold = true;
      } else if (data.label === '成品类') {
        this.tableData = this.tableData1[3].children;
      } else if (data.label === '其他类') {
        this.tableData = []
      } else if (data.label === '设备类') {
        this.tableData = []
      } else if (data.label === '模具类') {
        
        this.tableData = this.tableData1[4].children;
        this.isMold = false;
        console.log(this.tableData)
      } else if(data.label === "塑胶类模具"){
        
        this.tableData = this.tableData1[4].children;
        this.isMold = false;
      } else if(data.label === "密胺类模具"){
        console.log(data.label)
        console.log(this.tableData1)
        this.tableData = this.tableData1[4].children;
        this.isMold = false;
      }
      else if(data.label === "底标类"){
        this.isLabel = true;
        this.tableData = []
      } else if(data.label === "底标"){
        this.isLabel = true;
        this.tableData = []
      }
    },
    submitForm(){
      this.$confirm('确认提交吗？').then(() => {
       /*  this.loading = true; */
        if(this.title == '新增原材料'){
         setTimeout(() => {
          this.tableData1[0].children.push(this.form)
          this.$message.success('新增成功');
          this.loading = false
        },1000)
        this.open = false;
        } 
      })
    },
    cancel(){
      this.open = false;
      this.index = 0
    },
    handleQuery() {
      this.loading = false;
    },
    resetQuery() {
    },
    handleAdd() {
      if(this.title == '新增模具类' || this.title == '新增塑胶类模具' || this.title == '新增密胺类模具'){
        this.openMold = true;
      } else if(this.title == '新增底标类' || this.title == '新增底标'){
        this.openBottomMark = true;
      } else {
         this.open = true;
        this.isEdit = false;
      }
     
    },
    handleUpdate(row) {
      this.title = '修改原材料'
      this.open = true;
      this.isEdit = false;
      this.form = row;
      
    },
    handleDelete() { },
    handleExport() { },
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.userId);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
   submitFormReference(){
      this.$confirm('确认提交吗？').then(() => {
        this.loading = true;
        setTimeout(() => {
          this.tableData1[0].children.push(this.formReference)
          this.$message.success('新增成功');
          this.loading = false        
        },1000)
        this.openReference = false;
      })
   },
   cancelReference(){
      this.openReference = false;
      this.formReference = {}
   },
   submitFormMold(){
        this.$refs['formMold'].validate((valid) => {
          if (valid) {
            this.$message.success('提交成功!');
            this.openMold = false;
          } else {
            return false;
          }
         });
   },
   cancelMold(){
      this.openMold = false;
      this.formMold = {}
   }
  },

}
</script>

<style>
.selected-row {
  background-color: yellow !important;
  /* 选中行的背景颜色 */
}
</style>
